package com.cmb.lk50.common.receiver;

import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;

import javax.servlet.http.HttpServletResponse;

/**
 * 默认Receiver，只记录http状态码
 *
 * Author       : 蒋俊钊 80256973
 * Date         : 2020/7/19
 * Copyright    (C) ChinaMerchantsBank
 */
public class HttpStatusReceiver extends ResponseReceiver {

    @Override
    public String receive(HttpServletResponse response) {
        return String.valueOf(response.getStatus());
    }

    @Override
    public String receive(ServerHttpResponse response) {
        HttpStatus statusCode = response.getStatusCode();
        return (statusCode != null) ? statusCode.toString() : "unknown";
    }
}
